<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 2017/6/2
 * Time: 下午1:07
 */
namespace backend\controllers;

class InterfaceController extends BackendController
{
    public function actionIndex()
    {
        $menus = $this->getMenus(\Yii::$app->user->identity->level);
//        var_dump($menus);
//        exit();
        return $this->render('index', ['menus' => $menus]);
    }

    public function actionSideMenus()
    {
        if (\Yii::$app->user->identity->level==1){
            $menus = $this->getMenus(\Yii::$app->user->identity->level);
        }else{
            $level=2;
            $menus = $this->getMenus($level);
            if (\Yii::$app->user->identity->login_flag!=1) {
             $menu=[];
            foreach ($menus as $key => $value) {
                if ($key!="menu_10") {
                    $menu[$key]=$value;
                }

            }
            $menus=$menu;
            }
        }
        if(\Yii::$app->user->identity->loginName=="007")
        {
            $menu=[];
            foreach ($menus as $key => $value) {
                if ($key!="menu_6" && $key!="menu_10" && $key!="menu_13") {
                    $menu[$key]=$value;
                }

            }
            $menus=$menu;
//             var_dump($menus);
        }
        exit(json_encode($menus, JSON_FORCE_OBJECT));
    }
}
